//
//  MySaleTicketCell.m
//  KuWeiPark
//
//  Created by Kevin Su on 15/4/29.
//  Copyright (c) 2015年 Clief. All rights reserved.
//

#import "MySaleTicketCell.h"

@implementation MySaleTicketCell

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)initWithDataWithIndexPath:(NSIndexPath *)indexPath{
    
    UIImage *left_image;
    UIImage *right_image;
    UIColor *backColor;
    NSString *price;
    switch (indexPath.row) {
        case 0:
        {
            price = @"10";
            left_image = [UIImage imageNamed:TicketImage_10_yuan_left];
            right_image = [UIImage imageNamed:TicketImage_10_yuan_right];
            backColor = TicketColor_10_yuan;
            break;
        }
        case 1:
        {
            price = @"20";
            left_image = [UIImage imageNamed:TicketImage_20_yuan_left];
            right_image = [UIImage imageNamed:TicketImage_20_yuan_right];
            backColor = TicketColor_20_yuan;
            break;
        }
        case 2:
        {
            price = @"30";
            left_image = [UIImage imageNamed:TicketImage_30_yuan_left];
            right_image = [UIImage imageNamed:TicketImage_30_yuan_right];
            backColor = TicketColor_30_yuan;
            break;
        }
        case 3:
        {
            price = @"30";
            //已过期的30元券
            left_image = [UIImage imageNamed:TicketImage_OutOfDate_left];
            right_image = [UIImage imageNamed:TicketImage_OutOfDate_right];
            backColor = TicketColor_OutOfDate;
            self.ticketOutofdateImageView.hidden = NO;
            break;
        }
        default:
            break;
    }
    self.ticketLeftImageView.image = left_image;
    self.ticketRightImageView.image = right_image;
    self.ticketBodyView.backgroundColor = backColor;
    self.ticketPriceLabel.text = price;
}

- (void)initWithData:(NSString *)price{
    
    self.ticketPriceLabel.text = price;
    UIImage *left_image;
    UIImage *right_image;
    UIColor *backColor;
    switch ([price intValue]) {
        case 10:
        {
            left_image = [UIImage imageNamed:TicketImage_10_yuan_left];
            right_image = [UIImage imageNamed:TicketImage_10_yuan_right];
            backColor = TicketColor_10_yuan;
            break;
        }
        case 20:
        {
            left_image = [UIImage imageNamed:TicketImage_20_yuan_left];
            right_image = [UIImage imageNamed:TicketImage_20_yuan_right];
            backColor = TicketColor_20_yuan;
            break;
        }
        case 30:
        {
            left_image = [UIImage imageNamed:TicketImage_30_yuan_left];
            right_image = [UIImage imageNamed:TicketImage_30_yuan_right];
            backColor = TicketColor_30_yuan;
            break;
        }
        default:
            break;
    }
    self.ticketLeftImageView.image = left_image;
    self.ticketRightImageView.image = right_image;
    self.ticketBodyView.backgroundColor = backColor;
}

@end
